<?php
	header('Content-Type: application/json');

	$returnObject = array();

	if ($_SERVER['REQUEST_METHOD'] != 'POST') {		
		$returnObject = (object) array(
			"error_code" => 1000,
			"error" => "不支持POST以外的其它方法"
		);
	} else {
		switch ($_REQUEST['v1']) {
			case 'getbooklists':
				include_once ('v1/getbooklists.php');

				$returnObject = getBookLists(@$_POST['uid'], @$_POST['limit'], @$_POST['page']);

				break;
			case 'appendbook':
				include_once ('v1/appendbook.php');

				$returnObject = appendBook(@$_POST['uid'], @$_POST['bid'], @$_POST['title'], @$_POST['author']);

				break;
			case 'removebook':
				include_once ('v1/removebook.php');

				$returnObject = removeBook(@$_POST['uid'], @$_POST['bid'], @$_POST['include_history']);

				break;
			case 'updatehistory':
				include_once ('v1/updatehistory.php');
				
				$returnObject = updateHistory(@$_POST['uid'], @$_POST['bid'], @$_POST['article_id'], @$_POST['article_title']);

				break;
			case 'checkupdate':
				include_once ('v1/checkupdate.php');

				$returnObject = checkUpdate(@$_POST['app_code'], @$_POST['version_code']);

				break;
		}
	}

	echo json_encode($returnObject);
?>